﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucTinTuc.ascx.cs" Inherits="STT.Admin.UserControls.ucTinTuc" %>

<%--<div id="content-header">
    <div id="breadcrumb">
        <a href="../Admin/Default.aspx?idpage=1" class="tip-bottom" data-original-title="Về bảng điều khiển">
            <i class="icon-home"></i>Trang chính
        </a>
        <a href="../Admin/Default.aspx?idpage=qltt" class="current">Quản lý tin tức</a>
        <a href="#" class="current">Danh sách tin tức</a>
    </div>
</div>--%>

<div class="widget-box">
    <div class="widget-title">
        <span class="icon"><i class="icon-th"></i></span>
        <h5>Danh sách tin tức</h5>

        <div id="search">
            <asp:TextBox ID="txtTimKiem" runat="server" placeholder="Nhập từ tìm kiếm..."></asp:TextBox>
            <button class="tip-left" data-original-title="Tìm kiếm">
                <asp:ImageButton ID="btSearch" runat="server" ImageUrl="~/img/icon-search.png" OnClick="btSearch_Click" />
            </button>
        </div>
    </div>

    <div class="widget-content nopadding">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
            <asp:GridView ID="gvTinTuc" runat="server" CssClass="table table-bordered table-hover"
                AutoGenerateColumns="False" DataKeyNames="MaTT"
                OnRowCommand="gvTinTuc_RowCommand"
                EnableViewState="False" OnPageIndexChanging="gvTinTuc_PageIndexChanging"
                OnRowDeleting="gvTinTuc_RowDeleting" AllowPaging="True" PageSize="20"
                ShowHeaderWhenEmpty="True">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="cbChonTat" runat="server" onclick="cbChonTat(this);" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="cbChon" runat="server" onclick="cbChon(this);" />
                        </ItemTemplate>
                        <ItemStyle Width="10px" HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
                    <%-- <asp:BoundField DataField="MaTT" HeaderText="Mã tin tức"
                        InsertVisible="False" ReadOnly="True" SortExpression="MaTT"
                        ItemStyle-CssClass="span1">
                        <ItemStyle CssClass="span1"></ItemStyle>
                    </asp:BoundField>--%>

                    <asp:TemplateField HeaderText="Tiêu đề" SortExpression="TieuDe">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# HttpUtility.HtmlDecode((string) Eval("TieuDe")) %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle CssClass="span2" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Tóm tắt" SortExpression="NDTomTat">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# HttpUtility.HtmlDecode((string) Eval("NDTomTat")) %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle CssClass="span2" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Loại tin tức" SortExpression="TenLoaiTT">
                        <ItemTemplate>
                            <asp:Label ID="Label29" runat="server" Text='<%# Bind("TenLoaiTT") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle CssClass="span2" />
                    </asp:TemplateField>
                    <asp:BoundField DataField="NguoiDang" HeaderText="Người đăng"
                        SortExpression="NguoiDang">
                        <ItemStyle CssClass="span1"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="NgayDang" HeaderText="Ngày đăng" DataFormatString="{0:dd-MM-yyyy}"
                        SortExpression="NgayDang">
                        <ItemStyle CssClass="span1"></ItemStyle>
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Chi tiết" SortExpression="TenPB" ItemStyle-CssClass="span1"
                        ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <a href="#thongTin" data-toggle="modal" onclick="GetThongTin('<%# Eval("NDChiTiet") %>')">
                                <img src="../../img/detail.jpg" alt="Alternate Text" />
                            </a>
                        </ItemTemplate>

                        <ItemStyle HorizontalAlign="Center" CssClass="span1"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Sửa" ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
                                Text="Sửa" CommandName="ChonSua" CommandArgument="<%#((GridViewRow)Container).RowIndex%>">
                                <img src="../../img/edit.jpg" alt="img" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Xóa" ShowHeader="False">
                        <ItemTemplate>
                            <%-- Bắt sự kiện nhấn nút xóa --%>
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Visible='<%# int.Parse(Eval("MaLoaiTT").ToString())>4 ? false :true %>'
                                OnClientClick="return confirm('Bạn có muốn xóa?')">
                                <img src="../../img/delete.jpg" alt="img" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    <asp:Label Text="Không có dữ liệu cần tìm." runat="server" CssClass="lbThongBao" />
                </EmptyDataTemplate>
            </asp:GridView>

            <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl">
                <asp:LinkButton ID="lbXoaTat" runat="server" CssClass="btn"
                    OnClick="lbXoaTat_Click" OnClientClick="return confirm('Bạn có muốn xóa?')">Xóa chọn</asp:LinkButton>
                <asp:LinkButton ID="lbThemMoi" runat="server" CssClass="btn" PostBackUrl="~/Admin/Default.aspx?idpage=itt">Thêm mới</asp:LinkButton>
            </div>
        </div>
    </div>
</div>

<asp:HiddenField ID="hfMaTinTuc" runat="server" />

<div id="thongTin" class="modal modal-big hide" aria-hidden="true" style="display: none;">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">×</button>
        <h3 runat="server" id="txtTieuDe">Nội dung chi tiết</h3>
    </div>
    <div class="modal-body">
        <label id="noidung"></label>
    </div>
    <div class="modal-footer">
        <a data-dismiss="modal" class="btn" href="#" id="cancel">Hủy</a>
    </div>
</div>

<script>
    $(document).ready(function () {
        $('.btValidate').click(function () {
            $('form').quickValidate();
        });
    });

    function GetThongTin(str) {
        $('#noidung').html(str);

    }
</script>
